#pragma once

#include "Protocol.h"
#include "Delayer.h"
#include "Tween.h"

class Hud : boost::noncopyable
{
public:
	Hud();

	void paint(QPainter& painter, QRectF rect, const Protocol::Data& data);

	void draw_rect(QPainter& painter, const QRectF& rect);
	void draw_line(QPainter& painter, const QLineF& line);
	void draw_text(QPainter& painter, const QPointF& point, const char* text, QTextOption option);
	void draw_motor(QPainter& paintr, const QPointF& pos, size_t motor_idx);

private:

	util::Delayer<tween::Linear<float>, float> m_voltage; //volts
	util::Delayer<tween::Linear<float>, float> m_current; //amperes
	util::Delayer<tween::Linear<float>, float> m_capacity; //0 - 1
	util::Delayer<tween::Linear<float>, float> m_tx_rssi; //db
	util::Delayer<tween::Linear<float>, float> m_rx_rssi; //db
	util::Delayer<tween::Linear<float>, float> m_roll;
	util::Delayer<tween::Linear<float>, float> m_pitch;
	util::Delayer<tween::Linear<float>, float> m_yaw;
	std::array<util::Delayer<tween::Linear<float>, float>, 8> m_rc_inputs;
	std::array<util::Delayer<tween::Linear<float>, float>, 4> m_motor_outputs;
	std::array<util::Delayer<tween::Linear<float>, float>, 4> m_motor_outputs_slow;
	util::Delayer<tween::Linear<float>, float> m_altitude;

	std::chrono::high_resolution_clock::time_point m_last_time;

	QPen m_main_pen;
	QPen m_outline_pen;

	QFont m_big_font;
	int m_big_font_height;
	QFont m_small_font;
	int m_small_font_height;

	std::chrono::high_resolution_clock::time_point m_last_tick;
	float m_last_fps;
};

